<?php

namespace app\api\validate;

use think\Validate;

class NoteValidate extends BaseValidate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'id'    => 'require|number|gt:0',
        'page'  => 'number|gt:0',
        'key'   => 'chsAlphaNum|gt:1',
        'code'  => 'require|alphaNum|length:4',
        'title' => 'require|min:6',
        'cover' => 'require',
        'note'  => 'require|min:6',
        'time'  => 'require|number|gt:0'
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'id.require'        =>'ID不能为空',
        'id.number'         =>'ID只能是数字',
        'id.gt'             =>'ID必能小于1',
        'key.chsAlphaNum'   =>'关键字不能包含特殊字符',
        'key.gt'            =>'关键字长度不能少于2',
        'page.gt'           =>'分页码不能小于1',
        'page.number'       =>'分页码只能是数字',
        'code.require'      =>'分享码不能为空',
        'code.alphaNum'     =>'分享码格式不正确',
        'code.length'       =>'分享码长度必须是4位',
        'title.require'     =>'标题必须填写',
        'title.chsDash'     =>'标题包含特殊符号',
        'title.min'         =>'标题长度不能低于6',
        'cover.require'     =>'分享封面不能为空',
        'time.require'      =>'分享天数不为空',
        'time.number'       =>'分享天数只能是数字',
        'time.gt'           =>'分享天数不能低于1',
        'note.require'      =>'笔记内容不能为空',
        'note.min'          =>'笔记内容长度不能低于6',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'list'          => ['page','key'],
        'type'          => ['page','id'],
        'sharelist'     => ['page'],
        'deleteShare'   => ['id'],
        'deleteNote'    => ['id'],
        'note'          => ['id'],
        'noteShare'     => ['code'],
        'addShare'      => ['id','title','cover','time'],
        'addNote'       => ['tid','title','note']
    ];


}
